<?php
namespace Admin\Controller;

class RuleController extends CommonController
{
    public $model = null;

    public function __construct()
    {
        parent::__construct();
        $this->model = M('admin_rule');
    }

    /**
     * 权限列表
     * @return [type]
     */
    public function index()
    {
        $where = [
            'parent_id' => 0,
        ];
        $datas = $this->model->where($where)->limit(false)->lists();

        $count = $this->model->where($where)->count();
        $this->assign('count', $count);

        $childs = $this->model->where('parent_id != 0')->select();
        foreach ($childs as $value) {
            $datas[$value['parent_id']]['childs'][] = $value;
        }
        unset($childs);

        $this->assign('datas', $datas);

        $this->assign('bread_crumb', $bread_crumb = generate_bread_crumb([
            '系统设置',
            '权限列表',
        ]));
        $this->display();
    }
}
